import { InjectionKey, Ref } from 'vue'
import { SwipeActionEvent } from './swipeAction'

/**
 * 滑动事件处理类型
 */
export type SwipeEventType = 'normal' | 'close'

/**
 * SwipeActionContext
 */
export type SwipeActionContext = {
  activeName: Ref<string[]>,
  addField: (field: SwipeActionItemContect) => void,
  removeField: (field: SwipeActionItemContect) => void,
  handleItemSwipe: (type: SwipeEventType, id: string) => void,
  handleItemClick: (type: SwipeActionEvent['type'], id: string, btnIndex?: number) => void
}

export type SwipeActionItemContect = {
  id: string,
  name: string | number
}

export const swipeActionContextKey: InjectionKey<SwipeActionContext> = 
  Symbol('swipeActionContextKey')
